Next | Prev | Up | Top | Contents | Index

Control Entry Point

The pfxioctl() entry point is called by the kernel when a user process executes the ioctl() system call (see the ioctl(2) reference page). This entry point is allowed in character drivers only. Block device drivers do not support it, and STREAMS drivers pass control information as messages.

For an overview of the relationship between the user process, kernel, and the control entry point, see "Overview of Device Control".

The prototype of the entry point is

int pfxioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp, int *rvalp);

The argument values are

devA dev_t value from which you can extract the major and minor device numbers.
cmdThe request value specified in the ioctl() call.
argThe optional argument value specified in the ioctl() call, or NULL if none was specified.
modeFlag bits specifying the open() mode, as associated with the file descriptor passed to the ioctl() system function.
crpA cred_t object--an opaque structure for use in authentication, describing the process that is in-context. Standard access privileges to the special device file have already been verified.
*rvalpThe integer result to be returned to the user process.

It is up to the device driver to interpret the cmd and arg values in the light of the mode and other arguments. When the arg value is a pointer to data in the process address space, the driver uses the copyin() kernel function to copy the data into kernel space, and the copyout() function to return updated values. (See the copyin(D3) and copyout(D3) reference pages, and also "Transferring Data".)


Choosing the Command Numbers
Supporting 32-Bit and 64-Bit Callers
User Return Value

Next | Prev | Up | Top | Contents | Index